<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<div class="nav-tabs-custom">
	<ul class="nav nav-tabs">
		<li class="active"><a href="#hdfsBytes" data-toggle="tab">HDFS IO Bytes</a></li>
		<li><a href="#hdfsOPs" data-toggle="tab">HDFS IO OPs</a></li>
		<li><a href="#diskIO" data-toggle="tab">Disk IO</a></li>
		<li><a href="#cpu" data-toggle="tab">CPU Usage</a></li>
		<li><a href="#memory" data-toggle="tab">Memory Usage</a></li>
		<li class="pull-right">
			<select class="form-control" ng-model="type" ng-change="typeChange()">
				<option ng-repeat="(type, value) in aggregationMap track by $index" value="{{type}}">By {{common.string.capitalize(type)}}</option>
			</select>
		</li>
	</ul>
	<div class="tab-content keepContent with-border">
		<div class="tab-pane active" id="hdfsBytes">
			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top HDFS Bytes Read</h3>
						<div chart class="jpm-chart-container" series="hdfsBtyesReadSeries" option="commonOption"></div>
						<div ng-if="!hdfsBtyesReadSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
							<tr>
								<th>Name</th>
								<th>Total</th>
							</tr>
						</thead>
						<tbody>
							<tr ng-repeat="item in hdfsBtyesReadSeriesList track by $index">
								<td class="text-break">
									<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
										{{item.name}}
									</a>
									<span ng-if="type !== 'job'">{{item.name}}</span>
								</td>
								<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>

			<hr/>

			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top HDFS Bytes Written</h3>
						<div chart class="jpm-chart-container" series="hdfsBtyesWrittenSeries"
							 option="commonOption"></div>
						<div ng-if="!hdfsBtyesWrittenSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in hdfsBtyesWrittenSeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="hdfsOPs">
			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top HDFS Read OPs</h3>
						<div chart class="jpm-chart-container" series="hdfsReadOpsSeries" option="opsOption"></div>
						<div ng-if="!hdfsReadOpsSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in hdfsReadOpsSeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>

			<hr/>

			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top HDFS Write OPs</h3>
						<div chart class="jpm-chart-container" series="hdfsWriteOpsSeries" option="opsOption"></div>
						<div ng-if="!hdfsWriteOpsSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in hdfsWriteOpsSeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="diskIO">
			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top File Bytes Read</h3>
						<div chart class="jpm-chart-container" series="fileBytesReadSeries" option="commonOption"></div>
						<div ng-if="!fileBytesReadSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in fileBytesReadSeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>

			<hr/>

			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top File Bytes Written</h3>
						<div chart class="jpm-chart-container" series="fileBytesWrittenSeries"
							 option="commonOption"></div>
						<div ng-if="!fileBytesWrittenSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in fileBytesWrittenSeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="cpu">
			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top CPU Usage</h3>
						<div chart class="jpm-chart-container" series="cpuUsageSeries" option="commonOption"></div>
						<div ng-if="!cpuUsageSeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in cpuUsageSeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="memory">
			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top Physical Memory Usage</h3>
						<div chart class="jpm-chart-container" series="physicalMemorySeries"
							 option="commonOption"></div>
						<div ng-if="!physicalMemorySeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in physicalMemorySeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>

			<hr/>

			<div class="row">
				<div class="col-sm-6 col-md-8 col-lg-9">
					<div class="jpm-chart chart-lg overlay-wrapper">
						<h3 class="text-center">Top Virtual Memory Usage</h3>
						<div chart class="jpm-chart-container" series="virtualMemorySeries" option="commonOption"></div>
						<div ng-if="!virtualMemorySeries._done" class="overlay">
							<i class="fa fa-refresh fa-spin"></i>
						</div>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 col-lg-3">
					<table class="table table-striped">
						<thead>
						<tr>
							<th>Name</th>
							<th>Total</th>
						</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in virtualMemorySeriesList track by $index">
							<td class="text-break">
								<a ui-sref="jpmDetail({siteId: site, jobId: item.name})" ng-if="type === 'job'" target="_blank">
									{{item.name}}
								</a>
								<span ng-if="type !== 'job'">{{item.name}}</span>
							</td>
							<td title="{{item.total}}">{{common.number.abbr(item.total, true)}}</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
